package com.hesc.minio.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * 根据文件后缀名，判断文件类型
 */

public class ContentTypeUtil {
    @Value("${filetype.soft}")
    String softType;
    @Value("${filetype.document}")
    String documentType;
    @Value("${filetype.video}")
    String videoType;
    @Value("${filetype.audio}")
    String audioType;
    @Value("${filetype.pic}")
    String pic;

    public String resolveSuffix(String fileSuffix) {
        if (softType.contains(fileSuffix)) {
            return "soft";
        } else if (documentType.contains(fileSuffix)) {
            return "document";
        } else if (videoType.contains(fileSuffix)) {
            return "video";
        } else if (audioType.contains(fileSuffix)) {
            return "audio";
        } else if (pic.contains(fileSuffix)) {
            return "picture";
        } else {
            return "unkown";
        }
    }
}
